﻿@inherits Blazorise.BarDropdownMenu
@if ( ParentDropdownState != null && ParentDropdownState.Mode != BarMode.VerticalInline )
{
    <div class="@( ParentDropdownState.Mode == BarMode.Horizontal ? HorizontalMenuClass : VerticalMenuClass )" @onmouseenter="@ParentBarDropdown.OnMouseEnterHandler" @onmouseleave="@ParentBarDropdown.OnMouseLeaveHandler">
        <ul @ref="@ElementRef" id="@SubMenuId" direction="ltr" class="@ClassNames" style="@StyleNames" role="menu" @attributes="@Attributes">
            @ChildContent
        </ul>
    </div>

}
else
{
    <ul @ref="@ElementRef" id="@SubMenuId" direction="ltr" class="@ClassNames" style="@StyleNames" role="menu" @attributes="@Attributes">
        @ChildContent
    </ul>
}
@code{
    string HorizontalMenuClass
        => $"ant-menu-submenu ant-menu-submenu-popup {( ParentDropdownState?.RightAligned == true ? "ant-menu-submenu-placement-bottomRight" : "ant-menu-submenu-placement-bottomLeft" )} {( ParentDropdownState?.Visible == true ? "" : "ant-menu-submenu-hidden" )}";

    string VerticalMenuClass
        => $"ant-menu-submenu ant-menu-submenu-popup {( ParentDropdownState?.RightAligned == true ? "ant-menu-submenu-placement-leftTop" : "ant-menu-submenu-placement-rightTop" )} {( ParentDropdownState?.Visible == true ? "" : "ant-menu-submenu-hidden" )}";

    [CascadingParameter( Name = "SubMenuId" )] string SubMenuId { get; set; }
}
